<?php
class Model_Ext2
{
	var $ext2LibDir;
	var $myextJsDir;
	var $myextCSSDir;
	

	function Model_Ext2() {
		$ext2Cfg = FLEA::getAppInf('ext2Cfg');
		$this->ext2LibDir = $ext2Cfg['ext2LibDir'];
		$this->myextJsDir = $ext2Cfg['myextJsDir'];
		$this->myextCSSDir = $ext2Cfg['myextCSSDir'];
		
	}
	function _loadExt2Js() {
		$out = '';
		$out .='<link rel="stylesheet" type="text/css" href="';
		$out .=$this->ext2LibDir . '/' . 'resources/css/ext-all.css" /> '."\n";
		$out .='<script type="text/javascript" src="';
		$out .=$this->ext2LibDir . '/' . 'adapter/ext/ext-base.js"></script>'."\n";
		$out .='<script type="text/javascript" src="';
		$out .=$this->ext2LibDir . '/' . 'ext-all.js"></script>'."\n";
		
		return $out;
	}//end [function loadExt2Js]

	function _loadCSS($cssfilename) {
		$out = '';
		$out .='<link rel="stylesheet" type="text/css" href="';
		$out .=$this->myextCSSDir . '/' . $cssfilename . '" /> '."\n";
		return $out;
	}
	
	function _loadJs($jsfilename) {
		$out = '';
		$out .='<script type="text/javascript" src="';
		$out .=$this->myextJsDir . '/' . $jsfilename . '"></script>'."\n";
		return $out;
	}//end [function loadJs]

	function out($filename ='',$isToOutExt2Js = true) {
		$out = '';
		if($isToOutExt2Js) {
			$out .=$this->_loadExt2Js();
		}
		if(is_array($filename))
		{
			
			foreach($filename as $fn)
			{
				if(strtolower(strrchr($fn,'.'))==='.js') {
					$out .=$this->_loadJs($fn);
				}
				if(strtolower(strrchr($fn,'.'))==='.css'){
					$out .=$this->_loadCSS($fn);
				}
				
			}
		}else{
			
				if(strtolower(strrchr($filename,'.'))=='.js') {
					$out .=$this->_loadJs($filename);

				}
				if(strtolower(strrchr($filename,'.'))=='.css' ){
					$out .=$this->_loadCSS($filename);
					
				}
		}
		
		return $out;
	}
}
?>